<?php
namespace backend\models\activeRecords;

use Yii;
use yii\db\ActiveRecord;

/**
 * This is the model class for table "{{%t_user_login_log}}".
 *
 * @property string $id 自增id
 * @property string $user_id 用户id
 * @property string $username 用户名
 * @property string $login_ip 登录ip
 * @property string $login_time 登录时间
 */
class TUserLoginLog extends ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%t_user_login_log}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['user_id', 'login_time'], 'integer'],
            [['username'], 'required'],
            [['username', 'login_ip'], 'string', 'max' => 50],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', '自增id'),
            'user_id' => Yii::t('app', '用户id'),
            'username' => Yii::t('app', '用户名'),
            'login_ip' => Yii::t('app', '登录ip'),
            'login_time' => Yii::t('app', '登录时间'),
        ];
    }

    public function getUser(){
        return $this->hasOne(TUser::className(),['username'=>'username']);
    }
}
